package com.advanced.collectionAndGeneric_1;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;

/**
 * HashMapDemo--有一个由多个邮箱组成的 email
 * 数据 lily@sohu.com,tom@163.com,rock@sina.com ，
 * 现在需要把 email 中的用户名和邮件地址分离，
 * 分离后以键值对应方式放入 HashMap 中。
 *
 * @author: Jovi
 * @createTime: 2017-05-17 14:59
 **/
public class HashMapDemo {
    public static void main(String[] args) {
        List<Student> studentList = new ArrayList();

        try {
            SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
            String d1Str = "2008-01-01";
            String d2Str = "2008-01-02";
            String d3Str = "2008-01-03";
            Date d1 = sf.parse(d1Str);
            Date d2 = sf.parse(d2Str);
            Date d3 = sf.parse(d3Str);
            Student s1 = new Student(1,"1",1,d1);
            Student s2 = new Student(2,"2",1,d2);
            Student s3 = new Student(3,"3",1,d3);
            studentList.add(s1);
            studentList.add(s2);
            studentList.add(s3);
            Collections.sort(studentList, new Comparator<Student>() {
                @Override
                public int compare(Student o1, Student o2) {

                    if (o1.getBirthday().after(o2.getBirthday())) {
                        return -1;
                    } else if (o1.getBirthday().before(o2.getBirthday())) {
                        return 1;
                    } else {
                        return 0;
                    }
                }
            });
        } catch (ParseException e) {
            e.printStackTrace();
        }
        System.out.println("/////////////排序之后///////////////");
        for (Student s : studentList) {
            System.out.println(s.getName());
        }

        System.out.println("========================");
        Iterator<Student> it =studentList.iterator();
        while (it.hasNext()) {
            if (it.next().getId() == 3) {
                it.remove();
            }
        }
        // for (Student s1 : studentList) {
        //     if (s1.getId() == 1) {
        //         studentList.remove(s1);
        //     }
        // }

        Integer b = 5;
        Integer c = 5;
        Integer a = b>c?b:c;
        System.out.println(a);
    }
}
